package com.wangzhixuan.controller;

import java.io.File;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.Resource;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import com.wangzhixuan.commons.base.BaseController;
import com.wangzhixuan.service.impl.TestService;

/**
 * @description：测试Controller
 * @author：zhixuan.wang @date：2015/10/1 14:51
 */
@Controller
@RequestMapping("/test")
public class TestController extends BaseController {
	protected Logger logger = LogManager.getLogger(getClass());
	
	@Autowired
	private TestService testService;

	/**
	 * 图标测试
	 * 
	 * @RequiresRoles shiro 权限注解
	 * 
	 * @return
	 */
	@RequiresRoles("test")
	@GetMapping("/dataGrid")
	public String dataGrid() {
		return "admin/test";
	}

	@GetMapping("/test")
	public String test() {
		logger.debug("Enter test...");
		// 测试注解
		testService.selectById(1L);
		testService.selectById(1L);
		testService.selectById(1L);
		return "admin/test";
	}

	/**
	 * 下载测试
	 * 
	 * @return
	 */
	@GetMapping("/down")
	public ResponseEntity<Resource> down() {
		File file = new File("/Users/lcm/Downloads/归档.zip");
		return download(file);
	}
}
